<%--
  @author  lk
  DateTime: 2020/6/23 11:31
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册</title>
</head>
<body>
<script type="text/javascript">
    function checkpassword() {
        var password = document.getElementById("reg-password").value;
        var repassword = document.getElementById("reg-password1").value;

        if(password == repassword) {
            document.getElementById("tishi").innerHTML="<br><font color='green'>两次密码输入一致</font>";
            document.getElementById("submit").disabled = false;

        }else {
            document.getElementById("tishi").innerHTML="<br><font color='red'>两次输入密码不一致!</font>";
            document.getElementById("submit").disabled = true;
        }
    }
</script>
<h1 style="text-align: center">注册</h1>
<hr>
<center>
    <form action="register" method="post">
        <%
            String username = request.getParameter("username");
            String password = request.getParameter("password");
            String email = request.getParameter("email");
            String workplace = request.getParameter("workplace");
            if (username==null && password==null && email==null && workplace==null){

        %>
        <table style="border: 1px">
            <tr>
                <td>*用户名</td>
                <td><input type="text" id="reg-username" name="username"></td>
            </tr>
            <tr>
                <td>*密 码</td>
                <td><input type="password"  id="reg-password" name="password"></td>
            </tr>
            <tr>
                <td>*重复密码</td>
                <td><input type="password" id="reg-password1" name="password1" onkeyup="checkpassword()" ><span id="tishi"></span></td>
            </tr>
            <tr>
                <td>*邮 箱</td>
                <td><input type="text" id="reg-email"  name="email"></td>
            </tr>
            <tr>
                <td>单 位</td>
                <td><input type="text" id="reg-workplace"  name="workplace"></td>
            </tr>
            <tr>
                <td><input  id="reg-sub" type="submit" value="注册"></td>
            </tr>
        </table>
        <%
            }else {
                if ("null".equals(username)) username="";
                else if ("null".equals(password)) password="";
                else if ("null".equals(email)) email="";
                else if ("null".equals(workplace)) workplace="";
        %>
        <table style="border: 1px">
            <tr>
                <td>*用户名</td>
                <td><input type="text" name="username" value="<%=username%>"></td>
            </tr>
            <tr>
                <td>*密 码</td>
                <td><input type="password" name="password" value="<%=password%>" ></td>
            </tr>
            <tr>
                <td>*重复密码</td>
                <td><input type="password" name="password1" value="<%=password%>"></td>
            </tr>
            <tr>
                <td>*邮 箱</td>
                <td><input type="text" name="email"value="<%=email%>" ></td>
            </tr>
            <tr>
                <td>单 位</td>
                <td><input type="text" name="workplace" value="<%=workplace%>"></td>
            </tr>
            <tr>
                <td><input type="submit" value="注册"></td>
            </tr>
        </table>
        <%
            }
        %>
    </form>
    <a href="login.jsp">我要登录</a>
</center>

</body>
</html>
